# # coding: utf-8

from __future__ import absolute_import, division, print_function, unicode_literals

from pypeg2 import List, attr, endl, maybe_some, name
from thrift2pyi.peg import Annotations, Consts, Enums, Exceptions, Imports, Services, Unions, cls


class Init(object):
    grammar = " ...", endl


class Struct(object):
    grammar = cls, name(), "(BaseModel):", endl, attr("annotations", Annotations), attr("init", Init), endl


class Structs(List):
    grammar = maybe_some(Struct)


class PYI(object):
    grammar = "# coding:utf-8", endl, attr("imports", Imports), endl, attr("consts", Consts), \
        attr("enums", Enums), endl, attr("structs", Structs), endl, attr("unions", Unions), endl, attr(
        "exceptions", Exceptions), endl, attr("services", Services)
